package com.kelvin.paopao.module.market.wallet.charge;

import com.kelvin.kelvinlib.utils.ToastUtil;
import com.kelvin.paopao.api.RetrofitService;
import com.kelvin.paopao.api.responseBean.CommonListResponse;

import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;

/**
 * Created by MCK on 2017/5/11.
 */

public class WalletChargePresenter implements IWalletChargePresenter {
    private ChargeActivity mView;


    public WalletChargePresenter(ChargeActivity view) {
        this.mView = view;
    }

    @Override
    public void chargeMoney(String money) {
        RetrofitService.recharge(money).subscribe(new Consumer<CommonListResponse>() {
            @Override
            public void accept(@NonNull CommonListResponse commonListResponse) throws Exception {
                if (commonListResponse.getReason().equals("成功")) {
                    ToastUtil.showToast(mView, "充值成功");
                    mView.finish();
                }
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(@NonNull Throwable throwable) throws Exception {

            }
        }, new Action() {
            @Override
            public void run() throws Exception {

            }
        });
    }

    @Override
    public void getData(boolean isRefresh) {

    }

    @Override
    public void getMoreData() {

    }
}
